﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Web;

namespace SaleManagement.Web.Controls
{
  public partial class ReportViewerControl : UserControl
  {
    protected ITemplate _documentMapContainer = null;
    protected DocumentMapContainer _container = null;

    public ReportViewer RptViewer { get { return rptViewer; } }

    public string ReportName
    {
      get { return rptViewer.ReportName; }
      set { rptViewer.ReportName = value; }
    }

    public XtraReport Report
    {
      get { return rptViewer.Report; }
      set { rptViewer.Report = value; }
    }

    public bool ReportToolbarsAutoWidth
    {
      get { return reportToolbarTop.Width == Unit.Percentage(100) || reportToolbarBottom.Width == Unit.Percentage(100); }
      set { reportToolbarTop.Width = reportToolbarBottom.Width = (value ? Unit.Percentage(100) : Unit.Empty); }
    }

    [TemplateContainer(typeof(DocumentMapContainer)), PersistenceMode(PersistenceMode.InnerProperty),]
    public ITemplate DocumentMapContainer
    {
      get { return _documentMapContainer; }
      set { _documentMapContainer = value; }
    }

    public Control FindControlInDocumentMapContainer(string id)
    {
      return _container.FindControl(id);
    }

    protected void Page_Init(object sender, EventArgs e)
    {
      if (_documentMapContainer != null)
      {

      }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
      DataBind();
    }
  }

  public class DocumentMapContainer : Control, INamingContainer { }
}